package com.aaa.system.controller;

import com.aaa.common.entity.AclPermission;
import com.aaa.common.vo.Result;
import com.aaa.system.service.AclPermissionService;
import com.aaa.system.vo.FenPermissionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/permission")
@Api(tags = "权限接口类")
public class AclPermissionController {

    @Autowired
    private AclPermissionService permissionService;

    @GetMapping("/getByUserid/{userid}")
    @ApiOperation(value = "根据用户id查询具有的权限")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(value = "用户名id",name = "userid")
            }
            )
    public Result<AclPermission> getByUserid(@PathVariable String userid){
        return permissionService.findByUserId(userid);
    }
    @GetMapping("getAllPermission")
    public Result<List<AclPermission>> getAlPermission(){
        return permissionService.findByUsername();
    }

    @GetMapping("findPermissionByRoleId/{roleId}")
    public Result<Map<String,Object>> findPermissionByRoleId(@PathVariable String roleId){
        return permissionService.findALl(roleId);
    }
    @PostMapping("/confirmFenPermission")
    public Result confirmFenPermission(@RequestBody FenPermissionVo fenPermissionVo){
        return permissionService.confirmFenPermission(fenPermissionVo);
    }
}
